package com.globallogic.threads.executors;

import java.util.concurrent.Callable;
import java.util.logging.Logger;

public class Work implements Callable<Double> {
	private static final Logger log = Logger.getLogger(Work.class.getName());
	private Double[][] data;
	
	public Work(Double[][] data) {
		super();
		this.data = data;
	}

	@Override
	public Double call() throws Exception {
		
		return findSum();
	}
	
	private Double findSum(){
		log.info(Thread.currentThread().getName() + " started his work to sum...");
		Double sum = new Double(0);
		for(Double[] arr : data){
			for(Double num: arr){
				sum += num;
			}
		}
		log.info(Thread.currentThread().getName() + " finished his work");
		
		return sum;
	}

}
